<?php
namespace app\admin\controller;
use think\Controller;
use think\Session;
use app\common\controller\Login;
use think\Request;
use think\Db;
class System extends Login
{
	public function cy()
	{
        $num = session::get('admin');

        $user = db('user')->where('id',$num)->find();

        $agent = $user['agent_id'];

		$data = db('setting')->where('agent_id',$agent)->find();

        $xia = 1;

		$this->assign('data',$data);

		return $this->fetch();
	}

	public function cy_ud()
	{
        $num = session::get('admin');

        $user = db('user')->where('id',$num)->find();

		$data = input('post.');

		$data['agent_id'] = $user['agent_id'];

		$model = db('setting')->where('agent_id',$user['agent_id'])->find();

		if($model){
            $static = db('setting')->where('agent_id',$user['agent_id'])->update($data);
        }else{
            $static = db('setting')->insert($data);
        }

		return $this->success('修改成功 !');
	}

	public function payment()
	{
		return $this->fetch();
	}

	public function pm_ud()
	{
		$data = input('post.');

		$dat['fid'] = session::get('admin');
		$dat['type_id'] = 2;
		$static = db('system')->where($dat)->update($data);

		if ($static) {
			return $this->success('修改成功 !');
		}
	}

    public function email()
    {
         $num = session::get('admin');

        $user = db('user')->where('id',$num)->find();

        $agent = $user['agent_id'];

        $data = db('setting')->where('agent_id',$agent)->find();



        $this->assign('data',$data);

        return $this->fetch();
    }

    public function email_ud()
    {
        $data = input('post.');

         $num = session::get('admin');

        $user = db('user')->where('id',$num)->find();

        $data['id'] = $user['agent_id'];

        //var_dump($data);die;
         db('setting')->update($data);

        return $this->success('修改成功！');
    }

    public function dada()
    {
         $num = session::get('admin');

        $user = db('user')->where('id',$num)->find();

        $agent = $user['agent_id'];

        $data = db('setting')->where('agent_id',$agent)->find();



        $this->assign('data',$data);

        return $this->fetch();
    }








}
